// 默认多语言
export const getLang = () => {
  return localStorage.getItem('lang') ? localStorage.getItem('lang') : 'zh'
}

// pinia持久化
export const setSessionStoragePinia = (piniaFunc: any, storeKey: string) => {
  const instance = piniaFunc()
  // @ts-ignore
  instance.$subscribe((_, state) => {
    sessionStorage.setItem(storeKey, JSON.stringify({ ...state }))
  })
  // 2. 获取保存的数据，先判断有无，无则用先前的
  const old = sessionStorage.getItem(storeKey)
  if (old) {
    instance.$state = JSON.parse(old)
  }
}
